package com.lmk.mkcc.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.lmk.mkcc.constants.RedisSystemdictionaryConstants;
import com.lmk.mkcc.domain.Systemdictionary;
import com.lmk.mkcc.mapper.SystemdictionaryMapper;
import com.lmk.mkcc.service.ISystemdictionaryService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.io.Serializable;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author kun
 * @since 2022-09-23
 */
@Service
@Slf4j
public class SystemdictionaryServiceImpl extends ServiceImpl<SystemdictionaryMapper, Systemdictionary> implements ISystemdictionaryService {
    @Autowired
    private RedisTemplate<Object,Object> redisTemplate;

    @Override
    @Cacheable(cacheNames = RedisSystemdictionaryConstants.COURSE_TYPE_TREE_DATA_CACHE_NAMES,key = RedisSystemdictionaryConstants.SYSTEM_DICTIONARY_KEY)
    public Page<Systemdictionary> selectPage(Page<Systemdictionary> page) {
        Page<Systemdictionary> systemdictionaryPage = super.selectPage(page);

        return systemdictionaryPage;
    }

    @Override
    @CacheEvict(cacheNames = RedisSystemdictionaryConstants.COURSE_TYPE_TREE_DATA_CACHE_NAMES,key = RedisSystemdictionaryConstants.SYSTEM_DICTIONARY_KEY)
    public boolean insert(Systemdictionary entity) {
        return super.insert(entity);
    }

    @Override
    @CacheEvict(cacheNames = RedisSystemdictionaryConstants.COURSE_TYPE_TREE_DATA_CACHE_NAMES,key = RedisSystemdictionaryConstants.SYSTEM_DICTIONARY_KEY)
    public boolean deleteById(Serializable id) {
        return super.deleteById(id);
    }

    @Override
    @CacheEvict(cacheNames = RedisSystemdictionaryConstants.COURSE_TYPE_TREE_DATA_CACHE_NAMES,key = RedisSystemdictionaryConstants.SYSTEM_DICTIONARY_KEY)
    public boolean updateById(Systemdictionary entity) {
        return super.updateById(entity);
    }
}
